package com.chuiyan.topnews;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;


public class Login extends AppCompatActivity {
    private ImageView imageView;
    private TextView textView;
    private CardView loginButton;
    private EditText name;
    private EditText password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);

        imageView = findViewById(R.id.close);
        textView = findViewById(R.id.registe);
        loginButton = findViewById(R.id.loginButton);
        name = findViewById(R.id.name);
        password = findViewById(R.id.password);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Login.this,Registe.class);
                startActivity(intent);
            }
        });
//        loginButton.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                login();
//            }
//        });
    }

//    private void login(){
//        TUser tUser = new TUser();
//        tUser.setuAdmin(0);
//        tUser.setuName(name.getText().toString());
//        tUser.setuNick(tUser.getuName());
//        tUser.setuPassword(password.getText().toString());
//        Gson gson = new Gson();
//
//        OkHttpClient client = new OkHttpClient();//创建OkHttpClient对象。
//        MediaType JSON = MediaType.parse("application/json; charset=utf-8");//数据类型为json格式，
//        String jsonStr = gson.toJson(tUser);
//        RequestBody body = RequestBody.create(JSON, jsonStr);
//        Request request = new Request.Builder()
//                .url("http://localhost:8080/ToutiaoServer/login")
//                .post(body)
//                .build();
//        client.newCall(request).enqueue(new Callback() {
//
//            @Override
//            public void onFailure(Call call, IOException e) {
//                Toast.makeText(getApplicationContext(),"登录成功",Toast.LENGTH_LONG).show();
//            }
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//                Toast.makeText(getApplicationContext(),"登录失败",Toast.LENGTH_LONG).show();
//            }
//        });
//    }
}

